/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.creditControl.managedbean;

import frm.creditControl.entity.CreditAccountEntity;
import frm.creditControl.session.CreditControlSessionBean;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;

/**
 *
 * @author ReinforceII
 */
@ManagedBean
@ViewScoped
public class viewCreditAccountManagedBean {
    
    @EJB
    CreditControlSessionBean creditControlSessionBean;
    
    private CreditAccountEntity selectedCreditAccount;

    /** Creates a new instance of viewCreditAccountManagedBean */
    public viewCreditAccountManagedBean() {

    }
    
    public List<CreditAccountEntity> getCreditAccounts(){
        
        return creditControlSessionBean.getAllCreditAccount();
    }

    /**
     * @return the selectedCreditAccount
     */
    public CreditAccountEntity getSelectedCreditAccount() {
        return selectedCreditAccount;
    }

    /**
     * @param selectedCreditAccount the selectedCreditAccount to set
     */
    public void setSelectedCreditAccount(CreditAccountEntity selectedCreditAccount) {
        this.selectedCreditAccount = selectedCreditAccount;
    }
    
    public void updateCreditAccount(ActionEvent event){
        
        creditControlSessionBean.saveChanges(selectedCreditAccount);
    }
}
